CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
ADD_SUBDIRECTORY(z)
ADD_SUBDIRECTORY(k)

PROJECT(t)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )

SET(A_SRC src/a.c)
SET(T_SRC src/t.c)

ADD_LIBRARY(a SHARED ${A_SRC})
TARGET_INCLUDE_DIRECTORIES(a PUBLIC ${PROJECT_SOURCE_DIR}/include)
TARGET_LINK_LIBRARIES(a -Wl,--whole-archive k -Wl,--no-whole-archive)

ADD_EXECUTABLE(t ${T_SRC})
TARGET_INCLUDE_DIRECTORIES(t PUBLIC ${PROJECT_SOURCE_DIR}/include)
TARGET_LINK_LIBRARIES(t	a)

#ADD_DEPENDENCIES(t a)
